﻿{extend name="common/base" /}
{block name="title"}新建网站角色 - 管理员管理{/block}
{block name="body"}
	<article class="clearfix pd-20">
		<form action="" method="post" class="form form-horizontal" id="form-admin-icon-add">
			<div class="row clearfix">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图标编码：</label>
				<div class="form-controls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="" placeholder="" id="icon" name="icon" >
				</div>
			</div>

			<div class="row clearfix">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
				</div>
			</div>
		</form>
	</article>
    <input type="hidden" name="add" value="{:url('icon/add')}">

{/block}
{block name="js"}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__LIB__/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__LIB__/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__LIB__/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
$(function(){

    $("#form-admin-icon-add").validate({
        rules:{
            icon:{
                required:true,
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
           
            var url = $("input[name='add']").val();
            var icon = $("input[name='icon']").val();
            $.ajax({
                url : url,
                data : { 
                    'icon' : icon,
                },
                type : 'post',
                dataType : 'json',
                success : function(ret){
                    if(0 == ret.code){
                        layer.msg(ret.msg, { icon:1,time:1000 });
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.location.replace(parent.location.href)
                        parent.layer.close(index);
                    }else{
                        layer.msg(ret.msg, { icon:2,time:1000 });
                    }
                }
            });
        }
    });
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
{/block}